using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;
using System.Windows.Forms;

namespace TestAppSetupCustomActions
{
	/// <summary>
	/// Summary description for CustomAction.
	/// </summary>
	[RunInstaller(true)]
	public class CustomAction : System.Configuration.Install.Installer
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public CustomAction()
		{
			System.Diagnostics.Trace.WriteLine( "CustomAction .ctor entry.");
			InitializeComponent();
			System.Diagnostics.Trace.WriteLine( "CustomAction .ctor exit." );
		}

		public override void Install(IDictionary stateSaver)
		{
			System.Diagnostics.Trace.WriteLine( "CustomAction.Install method entry.");
			base.Install (stateSaver);
			#if DEBUG
			// Requires admin priviledges:
			// System.Diagnostics.Debugger.Launch();
			#endif
			new InstallForm( ).ShowDialog( );
			System.Diagnostics.Trace.WriteLine( "CustomAction.Install method exit.");
		}

		public override void Uninstall(IDictionary savedState)
		{
			System.Diagnostics.Trace.WriteLine( "CustomAction.Uninstall method entry.");
			base.Uninstall (savedState);
			new UninstallForm( ).ShowDialog( );
			System.Diagnostics.Trace.WriteLine( "CustomAction.Uninstall method exit.");
		}

		public override void Commit(IDictionary savedState)
		{
			System.Diagnostics.Trace.WriteLine( "CustomAction.Commit method entry.");
			base.Commit (savedState);
			new CommitForm( ).ShowDialog( );
			System.Diagnostics.Trace.WriteLine( "CustomAction.Commit method exit.");
		}

		public override void Rollback(IDictionary savedState)
		{
			System.Diagnostics.Trace.WriteLine( "CustomAction.Rollback method entry.");
			base.Rollback (savedState);
			new RollbackForm( ).ShowDialog( );
			System.Diagnostics.Trace.WriteLine( "CustomAction.Rollback method exit.");
		}


		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}


		#region Component Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();
		}
		#endregion
	}
}
